Expression Value is Not Used (EVNU)

Description:

EVNU detects situations where the expression value is not used. For example, a variable is subsequently assigned two expressions. This message is also reported if the object produced by the new operator is not used, and the object creation operation has no side effects.

When the option Ignore null initializers is set in the audit's properties, EVNU ignores variables initialized with the null or zero (0) value even if this value is not used afterwards. This is considered a commonly used coding style.

Incorrect:

List copy(List list) {
    List newList = null;
    int i = list.size();
    for (i = list.size() - 1; i >= 0; i--) {
        ...
    }
    
    newList = new ArrayList();
    ...
}

Correct:

List copy(List list) {
    List newList = null;
    for (int i = list.size() - 1; i >= 0; i--) {
        ...
    }
    
    newList = new ArrayList();
    ...
}